package com.cx.service.impl;

import com.cx.mapper.BaseMapper;
import com.cx.pojo.Base;
import com.cx.service.BaseService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BaseServiceImpl implements BaseService {

    @Autowired  // 自动装配mapper
            BaseMapper baseMapper;

    @Override
    public int insert(Base base) {
        return baseMapper.insert(base);
    }

    @Override
    public int updateByPrimaryKey(Base base) {
        return baseMapper.updateByPrimaryKey(base);
    }

    @Override
    public int deleteByPrimaryKey(Integer baseId) {
        return baseMapper.deleteByPrimaryKey(baseId);
    }

    @Override
    public Base selectByPrimaryKey(Integer baseId) {
        return baseMapper.selectByPrimaryKey(baseId);
    }

    @Override
    public PageInfo<Base> selectAllBase(Base base) {
        PageHelper.startPage(base.getPageNum(), base.getPageSize());
        List<Base> bases = baseMapper.selectAllBase(base);
        return new PageInfo<>(bases);
    }
}
